<?php

class InMemcache {

    private $memcache;

    function __construct() {
        $op = parse_ini_file(dirname(__FILE__) . "/conf.ini", true);

        $host = $op['memcache']['host'];
        $port = $op['memcache']['port'];

        $this->memcache = new Memcache();
        $this->memcache->connect($host, $port);
    }

    /**
     * 获得memcache对象
     * @return type
     */
    public function getMemcache($key) {
        return $this->memcache->get($key);
    }

    /**
     * 设置资源到相应的键中
     * @param type $key
     * @param type $value
     * @return type
     */
    public function setMemcache($key, $value) {
        return $this->memcache->set($key, $value);
    }

}
